function selectAll()
{
	$("input[type='checkbox']").each(function(){this.checked=true;});
	return false;
}
function selectOpp()
{
	$("input[type='checkbox']").each(function(){this.checked=!this.checked;});
	return false;
}
function UnselectAll()
{
	$("input[type='checkbox']").each(function(){this.checked=false;});
	return false;
}

var sendMailData;
function SendMail(stype)
{
	sendMailData = {};
	sendMailData.mid = mid;
	sendMailData.stype = stype;
	
	if (stype == 'select')
	{
		var eids = [];
		$.each($("input[name='eid']"), function (i, n){
			if (this.checked)
				eids.push(this.value);
		});
		if (eids.length == 0){
			alert('你未选中邮件地址');
			return false;
		}
		
		sendMailData['eids[]'] = eids;
	}
	
	showSelectTemplate();
	
	return false;
}


function showSelectTemplate()
{
	$("#TB_window").remove();
	tb_show("", "#TB_inline?height=100&width=300&inlineId=myOnPageContent&modal=true&r="+Math.random());
}

function doSendMail()
{
	var mail_template = $('#mail_template').val();
	if (mail_template == 0)
	{
		alert("请选择发送模板");
		return false;
	}
	
	sendMailData.tid = mail_template;
	
	$('#btn_send').attr("disabled", true);
	$.post("./?m=admin&c=meet&a=send", sendMailData, function (data){
			alert("邮件已经加入发送队列，发送中...");
			tb_remove();
			$('#btn_send').attr("disabled", false);
	});
}